<?php
namespace Admin\Controller;
class OpinionController extends CommonController{
    public function _initialize() {
		parent::_initialize();
        $this->_mod = D('opinion');
    }

    public function _before_index() {
		$this->list_relation = true;
        $p = I('p',1,'intval');
        $this->assign('p',$p);
        $this->_ajaxedit = true;
    }

    protected function _search() {
        $map = array();
        ($time_start = I('get.time_start')) && $map['add_time'][] = array('egt', strtotime($time_start));
        ($time_end = I('get.time_end')) && $map['add_time'][] = array('elt', strtotime($time_end)+(24*60*60-1));
        ($keyword = I('get.keyword')) && $map['name|phone'] = array('like', '%'.$keyword.'%');
		if( $_GET['status']==null ){
            $status = -1;
        }else{
            $status = intval($_GET['status']);
        }
        $status>=0 && $map['status'] = array('eq',$status);
        $this->assign('search', array(
            'time_start' => $time_start,
            'time_end' => $time_end,
            'status'  => $status,
            'keyword' => $keyword
        ));
        return $map;
    }

    public function _before_edit(){
        $id = I('get.id');
        $info = $this->_mod->field('id,user_id')->where(array('id'=>$id))->find();
        $this->user = M('user')->where(array('id'=>$info['user_id']))->find();
    }


}